package com.study.talk.module.mapper;

import com.study.talk.module.entity.Friend;
import com.study.talk.module.entity.GroupUserInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.study.talk.module.entity.UserInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author thor
 * @since 2023-12-18
 */
@Mapper
public interface GroupUserInfoMapper extends BaseMapper<GroupUserInfo> {
    @Delete("delete from group_user_info where user_id = #{userId} and group_id = #{groupId}")
    void removeGroupUserInfo(Integer groupId, Integer userId);

    @Delete("delete from group_user_info where group_id = #{groupId}")
    void removeAll(Integer groupId);

    @Select("select * from group_user_info where  user_id=#{userId} and group_id=#{groupId}")
    GroupUserInfo queryHasMember(Integer groupId, Integer userId);

    @Select("SELECT b.* FROM group_user_info as a,user_info as b WHERE a.group_id=#{groupId} AND a.user_id=b.id")
    List<UserInfo> queryMembersUserInfo(Integer groupId);
}
